#ifndef CACHE_LINE_LRU_HPP
#define CACHE_LINE_LRU_HPP


#include "AssocContainer.h"
#include "CacheLine.hpp"
#include "CacheSet.hpp"
#include "Directory.h"

#include "cache_types.h"

#include <vector>

template<typename TData>
class CacheLineLRU {
   public:
      CacheLineLRU ()
      : _line(NULL), _prev(NULL), _next(NULL)
      {}

      ~CacheLineLRU ()
      {
         //if (this->_line!=NULL)
         //    delete this->_line;
      }

      inline CacheLineLRU * getPrev () const
      {
         return this->_prev;
      }

      inline void setPrev (CacheLineLRU * line)
      {
         this->_prev = line;
      }

      inline CacheLineLRU * getNext () const
      {
         return _next;
      }

      inline void setNext (CacheLineLRU * line)
      {
         this->_next = line;
      }

      inline address_t getAddress () const
      {
         return this->_line->getAddress();
      }

      inline Directory getDirectory () const
      {
         return this->_line->getDirectory();
      }


      inline void setAddress (address_t addr)
      {
         this->_line->setAddress(addr);
      }

      inline void setDirty()
      {
         this->_line->setDirty();
      }

      inline bool isDirty()
      {
         return this->_line->isDirty();
      }

      inline uint32_t countDirectory()
      {
            return this->_line->countDirectory();
      }
      inline void getDirEntry(Directory & dirEntry)
      {
            this->_line->getDirEntry(dirEntry);
      }

      inline void setDirectory(uint32_t thread)
      {
            this->_line->setDirectory(thread);
      }
    inline void setDirectory(uint32_t thread,uint32_t page)
      {
            this->_line->setDirectory(thread,page);
      }

      inline void resetDirectory(uint32_t thread)
      {
            this->_line->resetDirectory(thread);
      }
    inline void resetDirectory(uint32_t page,uint32_t thread)
      {
            this->_line->resetDirectory(page,thread);
      }
      inline void resetAllDirectory()
      {
            this->_line->resetAllDirectory();
      }
      inline TData getData() { return this->_line->getData();}
      inline void setData(TData data) { this->_line->setData(data);}


      CacheLine<TData> * _line;
   private:
      CacheLineLRU<TData> * _prev;
      CacheLineLRU<TData> * _next;
};

#endif
